

<%@page import="workboard.WorkboardVo"%>
<%@page import="workboard.Workboard"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
.worksview-main {
	width: 900px;
	height: 520px;
	font-family: 'Nanum Gothic', sans-serif;
	text-align: center;
}

.worksview-main input{
	font-family: 'Nanum Gothic', sans-serif;
}

.worksview-main textarea{
	font-family: 'Nanum Gothic', sans-serif;
}

.worksview-top2{
	width: 380px;
	margin-right: 20px;
	height:450px;
	float:left;
}

.worksview-top {
	width: 500px;
	height: 450px;
	float: left;
}

.worksview-top-title, .worksview-top-title2, .worksview-top-title3, .worksview-top-title5 {
	width: 100px;
	height: 50px;
	float: left;
	margin: 10px;
	color: white;
	text-align: center;
	line-height: 50px;
	vertical-align: middle;
	background-color: #160952;
}

.worksview-top-title4 {
	width: 100px;
	height: 150px;
	float: left;
	margin: 10px;
	color: white;
	text-align: center;
	line-height: 150px;
	vertical-align: middle;
	background-color: #160952;
}

.worksview-top-item,.worksview-top-item2,.worksview-top-item3, .worksview-top-item5{
	width: 360px;
	height: 50px;
	float: left;
	margin: 10px;
	line-height: 50px;
	vertical-align: middle;
}

.worksview-top-item4 {
	width: 360px;
	height: 150px;
	float: left;
	margin: 10px;
}

.worksview-top-item input {
	width: 100%;
	height: 95%;
	font-size: 25px;
	border: 1px solid silver;
}

.worksview-top-item2 input {
	width: 100%;
	height: 95%;
	font-size: 25px;
	border: 1px solid silver;
}

.worksview-top-item3 input {
	width: 100%;
	height: 95%;
	font-size: 25px;
	border: 1px solid silver;
}

.worksview-top-item4 textarea {
	width: 100%;
	height: 97%;
	font-size: 25px;
	border: 1px solid silver;
}

.worksview-bottom {
	width: 900px;
	height: 50px;
	margin-top : 10px;
	float: left;
	border-top: 1px solid silver;
}

.worksview-bottom-left, .worksview-bottom-right{
	width: 200px;
	height: 60px;
	float: left;
}

.worksview-bottom-center{
	width: 500px;
	height: 60px;
	text-align: center;
	float: left;
}

.worksview-bottom-right input {
	width: 60px;
	height: 40px;
	float: right;
	margin-top: 5px;
	margin-left: 10px;
	margin-right: 7px;
	border-radius: 5px;
}

.worksview-bottom-left input {
	width: 60px;
	height: 40px;
	float: left;
	margin-top: 5px;
	margin-right: 10px;
	border-radius: 5px;
}

#workview_page_btn1{
	width: 30px;
	height: 40px;
	font-size: 15px;
	margin-right:5px;
	border: 0px solid;
	background-color: transparent;
}

#workview_page_btn2{
	width: 65px;
	height: 40px;
	font-size: 15px;
	margin-right: 2px;
	border: 0px solid;
	background-color: transparent;
}

#workview_page_btn3{
	width: 30px;
	height: 40px;
	font-size: 15px;
	margin-left: 5px;
	border: 0px solid;
	background-color: transparent;
}

#workview_page_btn4{
	width: 30px;
	height: 40px;
	font-size: 15px;
	margin-left: 2px;
	border: 0px solid;
	background-color: transparent;
}

#workview_btn_numpage{
	width: 20px;
	height: 40px;
	font-size: 15px;
	border: 0px solid;
	background-color: transparent;
}

#workview_btn_numpage:hover, #workview_page_btn1:hover, #workview_page_btn2:hover,
#workview_page_btn3:hover, #workview_page_btn4:hover{
	font-weight: bold;
}

#none_content{
	width:300px;
	height:150px;
	text-align: center;
}

.none_content input{
	width: 50px;
	height: 40px;
	margin-top: 15px;
}

</style>
<script>
function goPage(page){
		
		var ff = document.search_form;
		ff.nowPage.value = page;
		ff.action='Main.jsp?inc_content=../work/Worksview.jsp&nowPage='+page;
		ff.submit();
	}
function Modify(){
	
	var part = document.getElementById("part").value;
	var serial = document.getElementById("serial").value;
	
	location.href ='Main.jsp?inc_content=../work/modify.jsp&serial='+serial+'&part='+part;
}
function Delete(){
	var serial = document.getElementById("serial").value;
	var part = search_form.part.value;
	
	if(confirm("정말 삭제하시겠습니까?"))
		location.href ='Main.jsp?inc_content=../work/delete.jsp&serial='+serial+'&part='+part;
}
	
function fileDownload(filename){
	url = "../work/filedownload.jsp?filename="+filename;
	wind = window.open(url, "win", "");
}

</script>
</head>
<body>
	<jsp:useBean id='WorkboardVo' class='workboard.WorkboardVo' />
	<jsp:setProperty property="*" name="WorkboardVo" />
	<%
		String sessionID = (String)session.getAttribute("mid");
		if(sessionID == null || sessionID == "") sessionID = "test";
		String adm = ("inzy");

		if(request.getParameter("nowPage") == null){
			if(session.getAttribute("nowPage") != null)
				WorkboardVo.setNowPage((Integer)session.getAttribute("nowPage"));
		}
		else{
			session.setAttribute("nowPage", WorkboardVo.getNowPage());
		}
		Workboard work = new Workboard();
		work.setVo(WorkboardVo);
		
		work.setNowPage(WorkboardVo.getNowPage());
		Vector<WorkboardVo> v = work.list();
		
	%>

	<%
		String str = request.getParameter("part");
			String mid = "";
	%>
	<div class="worksview-main">
		<%
			if(v.size() == 0){
		%>
		<div id="none_content" class="none_content">
		게시물이 없습니다.
		<p/>
		<input type="button" value="등록"
					onclick="location.href='Main.jsp?inc_content=../work/workinsert.jsp&part=<%=str%>'">
		</div>
		<%
			}else{
								
							for(int i=0; i<v.size(); i++){
								WorkboardVo m = v.get(i);
								
		%>

		<div class="worksview-top2">
			<img src="../upload/<%=m.getFilename2()%>"
				style="width: 100%; height: 100%; display: block;">
		</div>
			<div class="worksview-top">

			<div class="worksview-top-title">제　목</div>
				<div class="worksview-top-item">
				<input type="text" readonly value="<%=m.getSubject()%>">
			</div>
			
			<div class="worksview-top-title2">작 성 자</div>
					<div class="worksview-top-item2">
				<input type="text" readonly value="<%=m.getMid()%>">
				<input type='hidden' name='part' id='part' value='<%=m.getPart() %>'>
			</div>
			
				<div class="worksview-top-title3">작성일</div>
					<div class="worksview-top-item3">
						<input type="text" readonly value=<%=m.getMdate()%>>
						<input type="hidden" id='serial' name='serial' value=<%=m.getSerial()%>>
					</div>
			
				<div class="worksview-top-title4">내　용</div>
					<div class="worksview-top-item4">
					<textarea readonly style="resize:none"><%=m.getContent()%></textarea>
			</div>
			
			
				<div class="worksview-top-title5">파　일</div>
					<div class="worksview-top-item5">
					<%
						if(m.getFilename() != null && m.getFilename() != ""){
					%>
					<a href="#" onClick="fileDownload('<%=m.getFilename()%>')"><%=m.getFilename()%></a>

					<%
						}else{
					%>
					파일 없음.
					<%
						}
					%>

				</div>
			</div>
		<div class="worksview-bottom">
			<div class="worksview-bottom-left">
			<%
				if(sessionID.equals(adm)){	
			%>
				<input type="button" value="등록"
					onclick="location.href='Main.jsp?inc_content=../work/workinsert.jsp&part=<%=str%>'">
			<%
				}
			%>
			</div>
				<%
					
									}}
				%>
			<%
				if(v.size() != 0){
			%>
			<div class="worksview-bottom-center">
				<!-- 페이지 분리 영역 -->

				<%
					
					if(work.getNowBlock() > 1){
				%>
				<input type='button' value='start' id='workview_page_btn1' onClick='goPage(1)'> <input
					type='button' value='previous' id='workview_page_btn2'
					onClick='goPage(<%=work.getStartPage()-1%>)'>
				<%
					}
				%>
				<

				<%
					for(int p=work.getStartPage();p<=work.getEndPage();p++){
				%>
				<input type='button' value=<%=p%> id='workview_btn_numpage'  name='workview_btn_numpage' onClick='goPage(<%=p%>)'>

				<%
					}
				%>
				>

				<%
					if(work.getNowBlock() < work.getTotBlock()){
				%>
				<input type='button' value='next' id='workview_page_btn3'
					onClick='goPage(<%=work.getEndNo()+1%>)'> <input
					type='button' value='end' id='workview_page_btn4'  name='workview_page_btn' onClick='goPage(<%=work.getTotPage()%>)'>

				<%
					}
				%>

				<form name='search_form' method='post' action='Main.jsp?inc_content=../work/Worksview.jsp&nowPage'>
					<input type='hidden' name='nowPage' id='nowPage' value=<%=work.getNowPage()%>>
					<input type='hidden' name='part' value='<%=str %>'>
				</form>

			</div>
			<div class="worksview-bottom-right">
			<%
				if(sessionID.equals(adm)){	
			%>
				<input type="button" value="삭제" onclick="Delete()"> <input
					type="button" value="수정" onclick="Modify()">
				
			<%  } %>	
			</div>
			<%
				}
			%>
		</div> 
	</div>

</body>
</html>